package com.springcloud.learn;

import jdk.nashorn.internal.runtime.FindProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.Output;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.integration.annotation.InboundChannelAdapter;
import org.springframework.integration.annotation.IntegrationComponentScan;
import org.springframework.integration.annotation.Poller;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.GenericMessage;

import java.util.Date;

/**
 * @author Edison_lv  lvchangrong
 * @create 2017/12/15  16:50
 */
@EnableBinding(value={IntegrationSinkSender.SinkOutPut.class})
public class IntegrationSinkSender {

    private static Logger logger = LoggerFactory.getLogger(IntegrationSinkReceiver.class);

    @Bean
    @InboundChannelAdapter(value=SinkOutPut.OUTPUT,poller = @Poller(fixedDelay = "2000"))
    public MessageSource<Date> timerMesageSource(){
        return new GenericMessage<Date>(new Date());
    }


    public interface SinkOutPut{
        String OUTPUT="input";
        @Output(SinkOutPut.OUTPUT)
        MessageChannel output();
    }
}
